FROM ubuntu:18.04

MAINTAINER freephp "fightforphp@gmail.com"

# 替换源为国内阿里云的源
# 先备份
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak
COPY ./sources.list /etc/apt/
RUN apt-get -y update && apt-get -y upgrade
RUN apt-get install -y vim curl gcc wget graphviz
# 添加php7.4的源
RUN apt-get -y install software-properties-common
RUN add-apt-repository ppa:ondrej/php
RUN apt-get update
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN apt-get install -y php7.4 php7.4-dev
RUN apt-get install -y php7.4-curl php7.4-fpm php7.4-gd php7.4-mysqlnd php7.4-mbstring php7.4-ldap php7.4-soap php7.4-mongod php7.4-soap php7.4-sqlite3 \
php7.4-xml \
php7.4-zip \
php7.4-intl \
php7.4-imagick \
php7.4-xdebug

# 安装composer
RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
# 设置composer源为阿里云
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# 安装mysql
RUN apt-get install -y mysql-server mysql-client
# 添加nginx配置
RUN  add-apt-repository ppa:ondrej/nginx
RUN apt-get update
RUN apt-get install -y nginx

# 配置nginx
COPY ./default /etc/nginx/sites-available/default

# 编译方式安装redis 6.x
RUN cd ~ && mkdir /var/redistInstall
COPY ./redis-6.0.12.tar.gz /var/redistInstall/
RUN cd /var/redistInstall && tar xvf redis-6.0.12.tar.gz && \
mv redis-6.0.12 redis && cd redis && make && make install
# 配置redis
COPY ./redis.conf /var/redistInstall/
# 安装php redis扩展
RUN pecl install redis
RUN echo "extension=redis.so" >> /etc/php/7.4/cli/conf.d/20-redis.ini
# 添加启动脚本
ADD ./start.sh /start.sh
RUN chmod 755 /start.sh


CMD /start.sh && tail -f

# 暴露端口
EXPOSE 3306
EXPOSE 80
